package com.ctgu.蓝桥杯真题.B组2019;

import java.io.*;

/**
 * @author: Backdiy
 * @data: 2021/4/8 19:25
 * @desc:
 */
public class A组队 {
    public static void main(String[] args) throws IOException {
        int[][] arr = new int[21][6];
        int max = 0;
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 5; j++) {
                arr[i][j] = Input.nextInt();
            }
        }
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 20; j++) {
                for (int k = 0; k < 20; k++) {
                    for (int l = 0; l < 20; l++) {
                        for (int m = 0; m < 20; m++) {
                            if((i!=j && i!=k && i!=l && i!=m) &&
                                    (j!=k && j!=l && j!=m) &&
                                    (k!=l && k!=m) &&
                                    (l!=m)){
                                max = Math.max(arr[i][0]+arr[j][1]+arr[k][2]+arr[l][3]+arr[m][4],max);
                            }
                        }
                    }
                }
            }
        }
        Input.out.println(max);
        Input.out.flush();
    }
    static class Input {
        static StreamTokenizer streamTokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static PrintWriter out = new PrintWriter((new OutputStreamWriter(System.out)));
        static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        static int nextInt() throws IOException {
            streamTokenizer.nextToken();
            return (int) streamTokenizer.nval;
        }

        static double nextDouble() throws IOException {
            streamTokenizer.nextToken();
            return streamTokenizer.nval;
        }

        static long nextLong() throws IOException {
            streamTokenizer.nextToken();
            return (long) streamTokenizer.nval;
        }

        static String nextLine() throws IOException {
            return bufferedReader.readLine();
        }

        static char next() throws IOException {
            return (char) bufferedReader.read();
        }
    }
}
